using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using Sedna.Core.Controller;
using Sedna.Core.Controller.Common;
using com.paypal.sdk.core;

namespace Sedna.Payment.PayPal
{
    public class ECRedirectToPaymentSystemAction : AbstractAction
    {
        public override IActionResult Execute(IExecutionContext executionContext)
        {
            string transactionToken = (string)executionContext.CallContext["PayPalTransactionToken"];
            string environment = (string) executionContext.CallContext["PayPalEnvironment"];
            string redirectionURL = Config.Instance.GetLoginURL(environment);
            redirectionURL += "?cmd=_express-checkout&" + "&token=" + transactionToken;

            HttpContext.Current.Response.Redirect(redirectionURL);

            return CreateResult(successStatus);
        }
    }
}
